package com.weishu.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.weishu.core.entity.SfContract;
import com.weishu.core.mapper.SfContractMapper;
import com.weishu.core.service.ISfContractService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xsl
 * @since 2021-10-19
 */
@Service
public class SfContractServiceImpl extends ServiceImpl<SfContractMapper, SfContract> implements ISfContractService {

    @Autowired
    SfContractMapper sfContractMapper;

    @Override
    public List<SfContract> selectSfContractList(SfContract sfContract) {

        QueryWrapper queryWrapper = new QueryWrapper();

        //收房合同编号
        if(sfContract.getSfContractNo()!=null){
            queryWrapper.like("sfContractNo",sfContract.getSfContractNo());
        }

        //业主姓名
        if(sfContract.getOwnerName()!=null){
            queryWrapper.like("ownerName",sfContract.getOwnerName());
        }

        //小区名
        if(sfContract.getPremiseName()!=null){
            queryWrapper.like("premiseName",sfContract.getPremiseName());
        }

        //录入日期
        if(sfContract.getConInfoTime()!=null){
            queryWrapper.le("conInfoTime",sfContract.getConInfoTime());
        }
        if(sfContract.getConInfoTime2()!=null){
            queryWrapper.ge("conInfoTime",sfContract.getConInfoTime2());
        }

        List list = sfContractMapper.selectList(queryWrapper);

        return list;
    }

    @Override
    public int insertContract(SfContract sfContract) {

        int i = sfContractMapper.insert(sfContract);

        return i;
    }

    @Override
    public int updateContract(SfContract sfContract) {

        int i = sfContractMapper.updateById(sfContract);

        return i;
    }

    @Override
    public int deleteContract(SfContract sfContract) {

        int i = sfContractMapper.deleteById(sfContract.getId());

        return i;
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param sfContract 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SfContract> selectTSfContractList(SfContract sfContract)
    {
        return sfContractMapper.selectTSfContractList(sfContract);
    }

    @Override
    public List<SfContract> querylistcontract(SfContract tSfContract) {
        return sfContractMapper.querylistcontract(tSfContract);
    }
}
